function(set_common_compile_options target)
  target_include_directories(
    ${target} PRIVATE $<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/include>)
  target_link_libraries(${target} PRIVATE ${DEPENDENCE} ${ARGN})
endfunction()

# Install & uninstall targets
function(project_install)
  if(${ARGC} EQUAL 0)
    return()
  endif()

  set(PROJECT_CONFIG ${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake)
  set(VERSION_CONFIG ${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake)
  set(TARGETS_EXPORT_NAME ${PROJECT_NAME}Targets)
  set(PROJECT_NAMESPACE ${PROJECT_NAME}::)
  include(CMakePackageConfigHelpers)
  configure_package_config_file(
    ${PROJECT_SOURCE_DIR}/cmake/Config.cmake.in ${PROJECT_CONFIG}
    INSTALL_DESTINATION lib/cmake/${PROJECT_NAME})
  write_basic_package_version_file(
    ${VERSION_CONFIG}
    VERSION ${PACKAGE_VERSION}
    COMPATIBILITY AnyNewerVersion)

  export(
    TARGETS ${ARGN}
    NAMESPACE ${PROJECT_NAMESPACE}
    FILE ${TARGETS_EXPORT_NAME}.cmake)

  install(DIRECTORY ${PROJECT_SOURCE_DIR}/include/ DESTINATION include)
  install(
    TARGETS ${ARGN}
    EXPORT ${TARGETS_EXPORT_NAME}
    ARCHIVE DESTINATION lib
    LIBRARY DESTINATION lib
    RUNTIME DESTINATION bin
    INCLUDES
    DESTINATION include)
  install(
    EXPORT ${TARGETS_EXPORT_NAME}
    NAMESPACE ${PROJECT_NAMESPACE}
    DESTINATION lib/cmake/${PROJECT_NAME})
  install(FILES ${PROJECT_CONFIG} ${VERSION_CONFIG}
          DESTINATION lib/cmake/${PROJECT_NAME})

  if(NOT TARGET uninstall)
    configure_file(
      ${PROJECT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in
      ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake IMMEDIATE @ONLY)

    add_custom_target(
      uninstall COMMAND ${CMAKE_COMMAND} -P
                        ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
  endif()

endfunction()
